package com.xzy.c;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 说明：
 * 1、使用@Component等注解标注Bean
 * 2、通过XML或配置类设置组件扫描路径
 *
 * @author xzy
 * @date 2021/11/28 17:33
 */
public class Main {

    public static void main(String[] args) {
        method1();
        method2();
    }

    public static void method1() {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("scan.xml");
        TeacherService teacherService = applicationContext.getBean(TeacherService.class);
        System.out.println(teacherService);
    }

    public static void method2() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(TeacherConfig.class);
        TeacherService teacherService = applicationContext.getBean(TeacherService.class);
        System.out.println(teacherService);
    }
}
